home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DJEMU106.ARJ / E14.CC < prev    next >
C/C++ Source or Header  |  1991-04-22  |  2KB  |  101 lines

  1. #include "emu.h"
  2. #include "const.h"
  3.  
  4. void fchs()
  5. {
  6.   if (empty())
  7.     return;
  8.   st().sign ^= SIGN_POS^SIGN_NEG;
  9.   status_word &= ~SW_C1;
  10. }
  11.  
  12. void fabs()
  13. {
  14.   if (empty())
  15.     return;
  16.   st().sign = SIGN_POS;
  17.   status_word &= ~SW_C1;
  18. }
  19.  
  20. void ftst()
  21. {
  22.   switch (st().tag)
  23.   {
  24.     case TW_Z:
  25.       setcc(SW_C3);
  26.       break;
  27.     case TW_V:
  28.       if (st().sign == SIGN_POS)
  29.         setcc(0);
  30.       else
  31.         setcc(SW_C0);
  32.       break;
  33.     case TW_S:
  34.       if (val_same(st(), CONST_PINF))
  35.       {
  36.         setcc(0);
  37.         break;
  38.       }
  39.       else if (val_same(st(), CONST_NINF))
  40.       {
  41.         setcc(SW_C3);
  42.         break;
  43.       }
  44.       setcc(SW_C0|SW_C2|SW_C3);
  45.       exception(EX_I);
  46.       break;
  47.     case TW_E:
  48.       setcc(SW_C0|SW_C2|SW_C3);
  49.       exception(EX_SU);
  50.       break;
  51.   }
  52. }
  53.  
  54. void fxam()
  55. {
  56.   int c=0;
  57.   switch (st().tag)
  58.   {
  59.     case TW_E:
  60.       c = SW_C3|SW_C0;
  61.       break;
  62.     case TW_Z:
  63.       c = SW_C3;
  64.       break;
  65.     case TW_V:
  66.       if (st().sigh & 0x80000000)
  67.         c = SW_C2;
  68.       else
  69.         c = SW_C3|SW_C2;
  70.       break;
  71.     case TW_S:
  72.       if (val_same(st(), CONST_NAN))
  73.         c = SW_C0;
  74.       else if (val_same(st(), CONST_PINF))
  75.         c = SW_C2|SW_C0;
  76.       else if (val_same(st(), CONST_NINF))
  77.         c = SW_C2|SW_C0;
  78.       break;
  79.   }
  80.   if (st().sign == SIGN_NEG)
  81.     c |= SW_C1;
  82.   setcc(c);
  83. }
  84.  
  85. FUNC emu_14_table[] = {
  86.   fchs, fabs, emu_bad, emu_bad, ftst, fxam, emu_bad, emu_bad
  87. };
  88.  
  89. void emu_14()
  90. {
  91.   if (modrm > 0277)
  92.   {
  93.     (emu_14_table[modrm&7])();
  94.   }
  95.   else
  96.   {
  97.     //
  98.     emu_bad();
  99.   }
  100. }
  101.